package edu.rit.checkers;

/**
 * @author Ian Tewksbury (ict8574@rit.edu)
 *
 */
public class Helpers {	
	/**
	 * Parse the string args into int args.
	 * 
	 * @param args
	 * 	args[0] <startDepth> the start depth of the tree
	 * 	args[1] <increaseDepth> the amount to increase the depth of the tree
	 *by if time allows
	 * 	args[2] <maxTime> the max time to run the search
	 * 	args[3] <maxTimePerDepth> the max time to spend searching
	 * 
	 * @return the given args casted to ints
	 */
	public static int[] parseArgs(String[] args){
		int[] parsedArgs = null;
		
		if(args.length == 4) {
			parsedArgs = new int[4];
			try {
				parsedArgs[0] = Integer.parseInt(args[0]);
				parsedArgs[1] = Integer.parseInt(args[1]);
				parsedArgs[2] = Integer.parseInt(args[2]);
				parsedArgs[3] = Integer.parseInt(args[3]);
			} catch(NumberFormatException e) {
				parsedArgs = null;
			}
		}
		
		return parsedArgs;
	}
	
	/**
	 * calculates the maximum of the three given longs
	 * 
	 * @param l1 long 1
	 * @param l2 long 2
	 * @param l3 long 3
	 * @return the maximum of l1, l2, and l3
	 */
	public static long max(long l1, long l2, long l3) {
		return Math.max(l1, Math.min(l2, l3));
	}
}
